<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/ajax-1.0.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery_last.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery-1.4.2.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery-impromptu.2.7.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery-selected.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.form.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.form.wizard.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.lazyload.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.treeview.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.validate.js"></script>
<title>Login Form</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<script type="text/javascript">
	$(document).ready(function() {
		$("#b01").click(function() {
		var user = $("#user").val();
		var psw = $("#psw").val();
		if(user.length==0||psw.length==0){
		alert("用户名或者密码为空");
		}else{
		var url = "<%=request.getContextPath()%>/login.do?method=loginSingle&user="+user+"&psw="+psw;
											$.ajax({
														type : "post",
														url : url,
														datatype : "json",
														contentType : "application/x-www-form-urlencoded; charset=utf-8",
														success : function(data) {
														alert(data);
															if (data == "1") {
																alert("登录成功");
																 $("#b03").text(user);
															} else if (data == "2") {
																alert("该用户已登录");
															}else if (data == "4") {
																alert("已有用户登录");
															}else{
															  alert("登录失败");
															   $("#b03").text("no login!");
															 }
														},
														error : function(
																XMLHttpRequest,
																textStatus,
																errorThrown) {
															alert(errorThrown);
														}
													});
									}	});
										
					});
				$(function(){
		               var url = "<%=request.getContextPath()%>/login.do?method=ResUser";
											$.ajax({
														type : "post",
														url : url,
														datatype : "json",
														contentType : "application/x-www-form-urlencoded; charset=utf-8",
														success : function(data) {
														
															 if(data == "1"){
															  $("#b03").text("no login!");
															 }else{
															  $("#b03").text(data);
															 }
														},
														error : function(
																XMLHttpRequest,
																textStatus,
																errorThrown) {
															alert(errorThrown);
														}
													});
				
				});	
				
				
				
				
				
				
				$(document).ready(function() {
		$("#b02").click(function() {
		var url = "<%=request.getContextPath()%>/login.do?method=loginOut";
											$.ajax({
														type : "post",
														url : url,
														datatype : "json",
														contentType : "application/x-www-form-urlencoded; charset=utf-8",
														success : function(data) {
															if (data == "1") {
																alert("注销成功");
																location.href="index.jsp";
															} else {
																alert("注销失败，已注销!");
																location.href="index.jsp";
															}

														},
														error : function(
																XMLHttpRequest,
																textStatus,
																errorThrown) {
															alert(errorThrown);
														}
													});
										});
					});
</script>
<body>
	
	  
	<form id="saveAction" method="post" action=""> 
		
		<table>
			<tr>
				<td>姓名</td>
				<td><input id="user" name="user" type="text" /></td>
			</tr>
			<tr>
				<td>密码</td>
				<td><input id="psw" name="psw" type="text" /></td>
			</tr>
			<tr>
				<td colSpan="2" align="center"><input id="b01" type="button"
					value="提交" /> <input type="button" onclick="turnback()" value="返回" />
				</td>
			</tr>
		</table>
	</form>
	<input id="b02" type="button"	value="注销" />
	
	<div id="b03"></div>
	
	
</body>
</html>
